package com.marsrover;

public class Location {

	private int x;
	private int y;
	private char direction;

	public Location(String locationInfo) {
		try {
			String[] initDataArray = locationInfo.split(" ");
			x = Integer.parseInt(initDataArray[0]);
			y = Integer.parseInt(initDataArray[1]);
			direction = initDataArray[2].toCharArray()[0];
		} catch (NumberFormatException e) {
			throw new LocationFormatException();
		}
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public char getDirection() {
		return direction;
	}

	public void setDirection(char direction) {
		this.direction = direction;
	}

	@Override
	public String toString() {
		return String.format("%d %d %c", x, y, direction);
	}
}
